package com.loop.unclelend.ui.adapter

import android.graphics.Color
import androidx.recyclerview.widget.RecyclerView
import com.loop.unclelend.MyApplication
import com.loop.unclelend.R
import com.loop.unclelend.utils.adapter.UncleRecyclerViewAdapter
import com.loop.unclelend.utils.adapter.UncleViewHolderHelper
import org.json.JSONObject

/**
 * UncleLend
 * @Author wwdeng
 * @CreateTime: 2024/9/25 14:42
 * @Annotation：贷款申请 选择时间 适配器
 */
class Adapter_Apply_Days(recyclerView: RecyclerView?) : UncleRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.uncle_item_apply_days) {
    override fun setItemChildListener(helper: UncleViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.txt_day) //点击Item
    }

    override fun fillData(helper: UncleViewHolderHelper, position: Int, model: JSONObject) {
        val textDays = helper.getTextView(R.id.txt_day)
        textDays.text = String.format(MyApplication.app.getString(R.string.loan_product_loan_term_value),model.optString("day"))

        if (model.optBoolean("isEnabled",true)){//可选
            if (model.optBoolean("isSelect",false)){
                textDays.setBackgroundResource(R.drawable.circle_fill_ff7000ff)
                textDays.setTextColor(Color.parseColor("#FFFFFFFF"))
            } else {
                textDays.setBackgroundResource(R.drawable.circle_fill_fff2f0f5)
                textDays.setTextColor(Color.parseColor("#FF000000"))
            }
        } else {//不可选
            textDays.setBackgroundResource(R.drawable.circle_fill_ffe6e4e9)
            textDays.setTextColor(Color.parseColor("#FFFFFFFF"))
        }
    }
}